package com.woniu.airent.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.airent.dto.HouseDto;
import com.woniu.airent.service.HouseManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("manageHouse")
public class ManageHouseController {

    @Autowired
    HouseManageService houseManageService;

    @RequestMapping("/list")
    @ResponseBody
    public PageInfo<HouseDto> listCheckedHouse(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "2") int pageSize) {
        PageInfo<HouseDto> houseDtoPageInfo = houseManageService.listInfor(pageNum, pageSize);
        return houseDtoPageInfo;
    }


    @RequestMapping("/change")
    @ResponseBody
    public String change(int id,int status) {
        int result = houseManageService.change(id,status);
        return result!=0?"success":"error";
    }






}
